using UnityEngine;
using System.Collections;

public class Bullet : MonoBehaviour {
	
	public float speed;
	public CharMovement c;
	
	void Start () {
	
		transform.Rotate(new Vector3(-90, 0, 0));
		c = GameObject.FindGameObjectWithTag("Player").GetComponent<CharMovement>();
		Destroy (gameObject, 2);
	}
	
	void Update () 
    {
		transform.Translate (Vector3.up * -speed);
	}
	
	void OnTriggerEnter (Collider other)
	{
		if (other.tag == "Enemy")
		{
			Enemy enemy = other.gameObject.GetComponent<Enemy>();
			enemy.removeHP(c.damage);
			Destroy (gameObject);
		}
	}
}
